//
//  TJBottomView.swift
//  TJSinaWeibo
//
//  Created by 唐后能 on 16/4/15.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit
import SnapKit

class TJBottomView: UIView {

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI ()
    }
    
    private func setupUI () {
    
        // 1,添加子控件.
        addSubview(transeferBtn)
        addSubview(commentBtn)
        addSubview(zanBtn)
        addSubview(line1)
        addSubview(line2)
        
        // 2,添加约束.
        // 转发.
        transeferBtn.snp_makeConstraints { (make) -> Void in
            make.top.leading.bottom.equalTo(self)
        }
        
        // 评论.
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(transeferBtn)
            make.leading.equalTo(transeferBtn.snp_trailing)
            make.size.equalTo(transeferBtn)
        }
        
        // 赞.
        zanBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(transeferBtn)
            make.leading.equalTo(commentBtn.snp_trailing)
            make.size.equalTo(transeferBtn)
            make.trailing.equalTo(self)
        }
        
        // 线1.
        line1.snp_makeConstraints { (make) -> Void in
            make.top.bottom.trailing.equalTo(transeferBtn)
            make.width.equalTo(1)
        }
        
        // 线2.
        line2.snp_makeConstraints { (make) -> Void in
            make.top.bottom.trailing.equalTo(commentBtn)
            make.width.equalTo(1)
        }
        
        
    }
    
    // MARK - 懒加载子控件.
    // 转发.
    private lazy var transeferBtn:UIButton = UIButton(content: "转发", bgImgnName: "timeline_card_bottom_background", bgHigllightImgName: "timeline_card_bottom_background_highlighted", ImgName: "timeline_icon_retweet")
    
    // 评论.
    private lazy var commentBtn:UIButton = UIButton(content: "评论", bgImgnName: "timeline_card_bottom_background", bgHigllightImgName: "timeline_card_bottom_background_highlighted", ImgName: "timeline_icon_comment")
    
    // 赞.
    private lazy var zanBtn:UIButton = UIButton(content: "赞", bgImgnName: "timeline_card_bottom_background", bgHigllightImgName: "timeline_card_bottom_background_highlighted", ImgName: "timeline_icon_unlike")
    
    // 线1
    private var line1:UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
    
    // 线2
    private var line2:UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))

}
